home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / D51_NARexx / ParentToDest.dopus5 < prev    next >
Text File  |  1995-12-26  |  3KB  |  88 lines

  1. /* ParentToDest for Directory Opus 5.
  2.  By Leo 'Nudel' Davidson for Gods'Gift Utilities
  3.  email: leo.davidson@keble.oxford.ac.uk  www: http://info.ox.ac.uk/~kebl0364/
  4.  
  5. $VER: ParentToDest.dopus5 1.3 (26.12.95)
  6.  
  7.    NOTE: This script _requires_ DOpus v5.11 or above.
  8.    NOTE: DOpusFuncs is an assembler version of this (and other) scripts.
  9.  
  10.    The scrips changes the DEST lister's path to the PARENT of the SOURCE
  11.    lister's path.
  12.  
  13.    If the parent directory does not exists (e.g. you're in the ROOT of a
  14.    volume), the DEST lister will show a device-list, reqtools-style.
  15.  
  16.    v1.00 -> v1.01 - Now (attempts to) add rexxsupport.library if it hasn't
  17.                     been added already.
  18.                     Now checks to make sure the DOPUS.x port exists.
  19.                     Some minor tidying up.
  20.                     Now works with paths with spaces in. (Thx Trevor).
  21.     v1.01 -> v1.2 - Now uses Show() instead of ShowList(). (Thanks Stoebi)
  22.                     Style Guide compliant version numbering and $VER string.
  23.      v1.2 -> v1.3 - No change to functionality.
  24.  
  25. Call as:
  26. ------------------------------------------------------------------------------
  27. ARexx    DOpus5:ARexx/ParentToDest.dopus5 {Qp}
  28. ------------------------------------------------------------------------------
  29. Turn off all switches.
  30. */
  31.  
  32. options results
  33. options failat 99
  34. signal on syntax;signal on ioerr        /* Error trapping */
  35. parse arg DOpusPort
  36. DOpusPort = Strip(DOpusPort,"B",'" ')
  37.  
  38. If DOpusPort="" THEN Do
  39.     Say "Not correctly called from Directory Opus 5!"
  40.     Say "Load this ARexx script into an editor for more info."
  41.     EXIT
  42.     END
  43. If ~Show("P",DOpusPort) Then Do
  44.     Say DOpusPort "is not a valid port."
  45.     EXIT
  46.     End
  47. Address value DOpusPort
  48.  
  49. If ~Show("L","rexxsupport.library") Then Do
  50.     AddLib("rexxsupport.library",0)
  51.     dopus request '"' || "'rexxsupport.library' had to be added to your system." || '0a'x || "If you don't have this (standard) library, your machine may crash!" || '0a'x || "(This is an ARexx problem, not my fault!)" || '0a0a'x || "You should add this line to your user-startup:" || '0a'x || "SYS:RexxC/RxLib >NIL: rexxsupport.library 0 -30 0" || '" OK'
  52.     End
  53.  
  54. /* Note - There is no reliable way to see if a library was actually added
  55.           or not. Blame ARexx, not me! - In fact, when I added a library
  56.           that didn't exist and then tried a dud function, my machine
  57.           gurued. */
  58.  
  59. lister query source stem source_handle.
  60.  
  61. IF source_handle.count = 0 | source_handle.count = "SOURCE_HANDLE.COUNT" Then Do
  62.     dopus request '"You must have a SOURCE lister!" OK'
  63.     EXIT
  64.     End
  65.  
  66.  
  67. lister query dest stem dest_handle.
  68.  
  69. IF dest_handle.count = 0 | dest_handle.count = "DEST_HANDLE.COUNT" Then Do
  70.     dopus request '"You must have a DESTINATION lister!" OK'
  71.     EXIT
  72.     End
  73.  
  74.  
  75. lister query source_handle.0 path
  76. source_path = RESULT||"/"
  77.  
  78. If EXISTS(source_path) Then
  79.     lister read dest_handle.0 '"'||source_path||'"'
  80. Else do
  81.     lister set dest_handle.0 source
  82.     command "devicelist FULL"
  83.     lister set source_handle.0 source
  84.     End
  85.  
  86. syntax:;ioerr:                /* In case of error, jump here */
  87. EXIT
  88.